<?php

namespace app\demo\controller;

use think\App;

class Preg extends Base
{

    public function index() {
        $str = "[2024-10-12 11:23] POST /admin/test/index?name=Jiang";
        $str = "[2024-10-12 11:23] GET /admin/test/index?name=Jiang";
        // 正则匹配基本用法
        if(preg_match('/^\[(.*)\] (POST|GET) (.*)/',$str,$matches)) {
            pp($matches);
        }else {
            echo "不匹配";
        }
    }

    public function str_trim() {
        $param = request()->param();
        $str = $param['str'] ?? '';
        $res = str_replace(' ','',$str);
        pp([
            'str' => $str,
            'res' => $res,
            'len' => strlen($res)
        ]);
    }

}
